User error handling is performed differently across different software applications, suites, and platforms. Depending on the error that has occurred, the error may be handled differently by both the user and the application. Sometimes, an action is perceived to be a mistake by the user when the action is not considered an error by the application. For example, a user may type a word or phrase into a word processor application, or insert an object into a drawing application. These actions are not considered errors by the application, but may be considered as mistakes by the user. Because of these inadvertent errors or decision changes by the user, many applications and other software suites provide an “undo” method that allows a user to undo one or more of their previously performed actions.
One previous undo method stores states and references to objects before and during a “do” operation (e.g., write, insert, etc.) so that the old state may be restored at undo time. As a do operation is performed, “undo atoms” are stored in a log. Undo atoms corresponding to a do operation create a record of memory swaps that return the state of an application to the state existing before the do operation commenced. Correspondingly, the undo atoms may also be used to transfer the state of the application to the state existing before an undo operation commenced. Stated differently, each undo atom merely swaps memory so that the state of the application is returned to the state that was present before the do or undo operation. The state of the application is changed rather than another operation being performed within the application. This method has an advantage in that memory swaps do not throw an exception since no new memory is allocated. Throwing an exception involves identifying actions that can result in unexpected or undesired behavior and preventing it from happening. Throwing the exception also lets the entity that is requesting that behavior know about the avoided undesired behavior. The memory swaps associated with walking through the undo atoms have been a dependable method because it avoids the problem of throwing exceptions.
The disadvantages of such an undo method is that errors still may occur, and since the memory swap code is so different than the code used in the original “do” operation, these errors may be extremely difficult to debug. Also, restoring state is a viable option only for a limited number of operations. As more and more changes are made, the probability of not maintaining integrity of a state or returning to the correct state increases.